package com.momo.web.controller.sysSetting;

import com.momo.common.common.JSONResult;
import com.momo.common.req.sysSetting.user.SysUserReq;
import com.momo.service.sysSetting.SysUserService;
import com.momo.web.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Kagome on 2019/4/20.
 */
@RestController
@RequestMapping(value = "/platform/user", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@Slf4j
public class SysUserController extends BaseController {
    @Autowired
    private SysUserService sysUserService;

    @RequestMapping("/userPage/v1")
    public JSONResult userPage(@RequestBody SysUserReq sysUserReq) {
        return sysUserService.userPage(sysUserReq, this.redisUser());
    }

    @RequestMapping("/status/v1")
    public JSONResult status(@Validated(SysUserReq.Status.class) @RequestBody SysUserReq sysUserReq) {
        return sysUserService.userStatus(sysUserReq, this.redisUser());
    }

    @RequestMapping("/detail/v1")
    public JSONResult detail(@Validated(SysUserReq.Detail.class) @RequestBody SysUserReq sysUserReq) {
        return sysUserService.detail(sysUserReq, this.redisUser());
    }

    @RequestMapping("/userAdd/v1")
    public JSONResult add(@Validated(SysUserReq.Add.class) @RequestBody SysUserReq sysUserReq) {
        return sysUserService.userAdd(sysUserReq, this.redisUser());
    }

    @RequestMapping("/modify/v1")
    public JSONResult modify(@Validated(SysUserReq.Modify.class) @RequestBody SysUserReq sysUserReq) {
        return sysUserService.modify(sysUserReq, this.redisUser());
    }
    @RequestMapping("/changePwd/v1")
    public JSONResult changePwd(@Validated(SysUserReq.Permission.class) @RequestBody SysUserReq sysUserReq) {
        return sysUserService.changePwd(sysUserReq, this.redisUser());
    }
}
